//
//  WMParkWebViewController.m
//  witMorning
//
//  Created by Mac mini on 2018/1/16.
//  Copyright © 2018年 zt. All rights reserved.
//

#import "WMParkWebViewController.h"

@interface WMParkWebViewController ()

@end

@implementation WMParkWebViewController
-(void)setObj:(id)obj{
    _obj = obj;
    self.webView = [[WKWebView alloc]initWithFrame:self.view.bounds];
    [self.view addSubview:self.webView];
    self.webView.UIDelegate = self;
    self.webView.navigationDelegate = self;
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"park.html" ofType:nil]]];
        [self.webView loadRequest:request];
    

}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

}

-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    NSData *data = [NSJSONSerialization dataWithJSONObject:_obj options:NSJSONWritingPrettyPrinted error:nil];
    NSString *dataStr = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
    
    NSString *strr = [NSString stringWithFormat:@"load('%@')",dataStr];
    NSString *strrr = [[strr stringByReplacingOccurrencesOfString:@" " withString:@""] stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    [self.webView evaluateJavaScript:strrr completionHandler:^(id _Nullable obj, NSError * _Nullable error) {
        NSLog(@"%@,%@",obj,error);
    }];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
